import { getToken, setToken, removeToken } from "@/common/auth.js";	//token设置
const store = {
  state: {
		userinfo:''//获得本地储存的用户信息，that.$store.state.userinfo
  },
  mutations: {
	// 设置用户信息
	// uni.setStorageSync("userinfo",res.data.data);
	// that.$store.commit("login")
	
	// 获取用户信息
	login(state){  //获取登录信息this.$store.commit("login")
		state.userinfo = uni.getStorageSync('userinfo');
	},
	// 删除本地储存
	delStorage(state) {	
			  state.userinfo = '';
			  uni.clearStorage();    
	},
	
	
    // 设置token
    setToken(state, value){
      setToken(value);
    },
    // 删除token
    removeToken(state, value){
      removeToken();
    }
  },
  getters: {
  	  // 获取token
  	  getToken: (state) => (e) =>{
  		console.log('测试'+e)	//console.log(this.$store.getters.getToken(1))
  	    return getToken();
  	  }
  },
  actions: {}
};
export default store;
